package com.ajaxdwr;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.bean.ChinaBean;
import com.dao.DbDao;

public class China {
	public List<ChinaBean> getProvince() {
		List<ChinaBean> list = new ArrayList<ChinaBean>();
		String sql = "select provinceID, province from hat_province;";
		ResultSet rs = DbDao.queryDb(sql);
		list.add(new ChinaBean("", "请选择"));
		try {
			while (rs.next()) {
				list.add(new ChinaBean(rs.getString(1), rs.getString(2)));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			DbDao.close();
		}
		System.out.println("province:" + list);
		return list;
	}

	public List<ChinaBean> getCity(String father) {
		List<ChinaBean> list = new ArrayList<ChinaBean>();
		String sql = "select cityID, city from hat_city where father = '"
				+ father + "';";
		ResultSet rs = DbDao.queryDb(sql);
		list.add(new ChinaBean("", "请选择"));
		try {
			while (rs.next()) {
				list.add(new ChinaBean(rs.getString(1), rs.getString(2)));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			DbDao.close();
		}
		System.out.println("city:" + list);
		return list;
	}

	public List<ChinaBean> getArea(String father) {
		List<ChinaBean> list = new ArrayList<ChinaBean>();
		String sql = "select areaID, areas from hat_area where father = '"
				+ father + "';";
		ResultSet rs = DbDao.queryDb(sql);
		list.add(new ChinaBean("", "请选择"));
		try {
			while (rs.next()) {
				list.add(new ChinaBean(rs.getString(1), rs.getString(2)));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			DbDao.close();
		}
		System.out.println("area:" + list);
		return list;
	}
}
